<template>
  <div class="mineBg">
    <!-- <HeadNav :title="'今日填报'"></HeadNav> -->
    <div class="content">
      <div class="userImg">
        <div class="imgBg"><img
                             src="https://17lelife-bucket.oss-cn-beijing.aliyuncs.com/WeChat-App-Picture/my/info.png"
                             alt=""
                             v-if="isShow">
          <div class="userRoleText">张同名</div>
        </div>
        <div class="userInfo">
          <div class="userInfo-name">张同名</div>
          <div class="userInfo-tel">1523620364</div>
        </div>
      </div>
      <div class="contentTop">
        <van-cell-group :border="false">
          <van-cell
            size="large"
            title="角色"
            :value="userRole" >
            <template #icon>
              <img
                src="../../assets/images/userRole.png"
                alt=""
                style="width: 18px; height: 14px;">
            </template>
          </van-cell>
          <van-cell
            size="large"
            title="归属"
            value="第一档口"
            v-if="userRole.indexOf('档口') > -1">
            <template #icon>
              <img
                src="../../assets/images/userDangkou.png"
                alt=""
                style="width: 16px; height: 16px;">
            </template>
          </van-cell>
          <van-cell
            size="large"
            title="修改密码"
            is-link
            url="">
            <template #icon>
              <img
                src="../../assets/images/editPassWord.png"
                alt=""
                style="width: 16px; height: 16px;">
            </template>
          </van-cell>
        </van-cell-group>
      </div>
      <div class="btnArea">
        <van-button
          type="primary"
          class="loginBtn"
          @click="logout()">退出登录 </van-button>
      </div>
    </div>
    <foot></foot>
  </div>
</template>

<script>
/* eslint-disable */
// import { getApplyCertificationPagePho, getVerifyTypeList } from '@/api/api'
import { getParams } from '@/common/public'
// import HeadNav from '@/components/HeadNav'
import foot from '../foot/foot.vue'
import moment from 'moment'
// import { mapState } from 'vuex'
export default {
    name: 'MineInfo',
    components: {
        // HeadNav,
        foot
    },
    computed: {
        // ...mapState({
        //     token: (state) => state.applyrecords.token
        // })
    },
    watch: {
        active(newVal) {
            console.log('newVal', newVal)
            if (newVal === 0) {
                this.params.applyType = null
                this.loading = true
                this.contentData = []
                this.finished = false
                if (!this.finished) {
                    this.onLoad(1)
                }
            } else if (newVal === 0) {
                this.params.applyType = newVal
                this.loading = true
                this.contentData = []
                this.finished = false
                if (!this.finished) {
                    this.onLoad(1)
                }
            } else {

            }
        }
    },
    data() {
        return {
            active: 2,
            userRole:'档口工作人员',
            userRoleText:'档口',
            tabData: [
                {
                    typeId: 0,
                    typeName: '全部'
                },
                {
                    typeId: 1,
                    typeName: '转校'
                },
                {
                    typeId: 2,
                    typeName: '职务认证'
                },
                {
                    typeId: 3,
                    typeName: '学历认证'
                },
                {
                    typeId: 4,
                    typeName: '职称认证'
                },
                {
                    typeId: 5,
                    typeName: '空间认证'
                }
            ],
            // tabDatasss: [
            //     {
            //         typeId: 0,
            //         typeName: '全部'
            //     }],
            // contentData: [],
            // applyRecords: {},
            // finishedText: '没有更多了',
            // loading: false,
            // finished: false,
            // offset: 0, // 滚动条与底部距离小于 offset 时触发load事件，默认300
            // pageNo: 1, // 当前页码
            // pageSize: 10, // 分页大小
            // total: 0, // 查询总条数

            // params: {
            //     pageNo: 1,
            //     pageSize: 10,
            //     applyType: undefined,
            //     applyStatus: 0,
            //     access_token: sessionStorage.getItem('Authorization'),
            //     tenantId: '002'
            // },
            // paramsStatus: {
            //     access_token: sessionStorage.getItem('Authorization'),
            //     tenantId: '002'
            // },
            isShow:false,
        }
    },
    mounted() {
        // // window.onPageFinished = this.onPageFinished
        // // this.$bridge.registerhandler('onPageFinished')
        // // Android端
        // // window.android.showToast('展示内容提示')
        // // window['onPageFinished'] = (data) => {

        // const u = navigator.userAgent
        // const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 // g
        // const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) // ios终端
        // if (isAndroid) {
        //     window.android.hideToolbar()
        //     window.android.setEnableSwipeBack(true)
        // }
        // if (isIOS) {
        //     var s = {}
        //     this.$bridge.callhandler('hideToolbar', s, (data) => { })
        // }
        // // }
        console.log(777, localStorage.getItem('lin'))

        // this.$nextTick(() => {
            if (localStorage.getItem('lin')=== 'stockIn') {
                this.userRole = '入库工作人员'
                this.userRoleText='入库'
            } else if (localStorage.getItem('lin') === 'true') {
                this.userRole = '档口工作人员'
                this.userRoleText='档口'
            } else if (localStorage.getItem('lin')=== 'stockOut') {
                this.userRole = '出库工作人员'
                this.userRoleText='出库ß'
            } else if (localStorage.getItem('lin')=== 'supplier') {
                this.userRole = '供应商工作人员'
                this.userRoleText='供应商'
            }
        // })

    },
    created() {
        // // 保存token
        // // localStorage.setItem('Authorization', '')
        // const Authorization = getParams('access_token')
        // this.$store.commit('applyrecords/setToken', Authorization)
        // // this.$store.state.area.areaSelect
        // console.log(
        //     'this.$store.state.applyrecords.token',
        //     this.$store.state.applyrecords.token
        // )
        // console.log(Authorization)
        // console.log(location.href)
        // localStorage.setItem('Authorization', Authorization)
        // if (!sessionStorage.getItem('Authorization')) {
        //     sessionStorage.setItem('Authorization', Authorization)
        // }

        // console.log(sessionStorage.getItem('Authorization'))
        // // 认证任务
        // // this.getApplyRecordPho()
        // // 获取认证类型
        // this.paramsStatus.access_token = sessionStorage.getItem('Authorization')
        // getVerifyTypeList(this.paramsStatus).then((res) => {
        //     if (res.statusCode === 0) {
        //         console.log('获取认证类型', res)
        //         const list = res.content.map((item, index) => {
        //             return {
        //                 typeId: item.typeId,
        //                 typeName: item.typeName
        //             }
        //         })
        //         console.log('list', list)
        //         if (list.length > 0) {
        //             this.tabDatasss = this.tabDatasss.concat(list)
        //             this.tabData = this.tabDatasss
        //             console.log('tabData1', this.tabData)
        //         }
        //         // this.tabData = this.tabData.concat(list)
        //         console.log('tabData2', this.tabData)
        //     } else {
        //         // this.$message.error(res.errorMessage)
        //     }
        // })
    },
    methods: {
        // beforeChange(index) {
        //     console.log('index', index)
        //     if (index === 0) {
        //         this.params.applyType = null
        //         this.loading = true
        //         this.contentData = []
        //         this.finished = false
        //         if (!this.finished) {
        //             this.onLoad(1)
        //         }
        //     } else {
        //         this.params.applyType = index
        //         this.loading = true
        //         this.contentData = []
        //         this.finished = false
        //         if (!this.finished) {
        //             this.onLoad(1)
        //         }
        //     }
        //     return true
        // },

        // handleDetails(item) {
        //     this.$router.push({
        //         path: '/authenticateDetails',
        //         query: { item: JSON.stringify(item) }
        //     })
        // },
        // getApplyRecordPho() {
        //     this.params.access_token = sessionStorage.getItem('Authorization')
        //     getApplyCertificationPagePho(this.params).then((res) => {
        //         if (res.statusCode === 0) {
        //             res.content.records.forEach((item) => {
        //                 item.applyTime = moment(item.applyTime).utc().format('YYYY-MM-DD')
        //                 if (item.verifyTime !== '' && item.verifyTime !== null) {
        //                     item.verifyTime = moment(item.verifyTime)
        //                         .utc()
        //                         .format('YYYY-MM-DD')
        //                 }
        //             })
        //             if (res.content.records === 0) {
        //                 // debugger
        //                 // 判断获取数据条数若等于0
        //                 this.contentData = [] // 清空数组
        //                 this.finished = true // 停止加载
        //                 this.finishedText = '暂无数据'
        //             }
        //             // 若数据条数不等于0
        //             this.total = res.content.total // 给数据条数赋值
        //             this.contentData.push(...res.content.records) // 将数据放入list中
        //             this.loading = false // 加载状态结束
        //             // 如果list长度大于等于总数据条数,数据全部加载完成
        //             console.log(this.contentData)
        //             if (this.contentData.length >= res.content.total) {
        //                 // this.finished = true // 结束加载状态
        //                 if (this.contentData.length > 0) {
        //                     this.finished = true // 结束加载状态
        //                     this.finishedText = '没有更多了'
        //                 } else {
        //                     this.finished = true // 结束加载状态
        //                     this.finishedText = '暂无数据'
        //                 }
        //             }
        //         } else {
        //             this.finishedText = '加载失败，请刷新后重试'
        //         }
        //     })
        // },
        // onLoad(val) {
        //     this.loading = true
        //     const timer = setTimeout(() => {
        //         // 定时器仅针对本地数据渲染动画效果,项目中axios请求不需要定时器
        //         this.getApplyRecordPho() // 调用上面方法,请求数据
        //         this.params.pageNo++ // 分页数加一
        //         if (val === 1) {
        //             // 每次搜索、或者初始化
        //             this.params.pageNo = 0
        //         }
        //         this.finished && clearTimeout(timer) // 清除计时器
        //     }, 100)
        // },
        toCheck() { },
        logout(){
            this.$router.push({ path: '/login' })
             // 清除所有 localStorage 数据
            localStorage.clear();
            console.log('LocalStorage 数据已全部清除');
        }
        
    },
    beforeDestroy() {
        console.log('index')
        window.removeEventListener('scroll', this.onLoad, true)
    }
}
</script>

<style lang="less" scoped>
span,
p {
    padding: 0;
    margin: 0;
}

.mineBg {
    background: url(../../assets/images/myBg.png) no-repeat;
    background-size: 100%;
    background-color: white;
    padding-top: 162px;
}


.content {
    // margin-top: 35px;
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    // align-items: center;
    height: calc(100vh - 2px);
    background: #fff;
    border-radius: 40px 40px 0px 0px ;
}

.userImg {
    position: absolute;
    text-align: center;
    top: -62px;
    left: calc((100% - 125px)/2);
    
.imgBg{
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    background-color: #F8F8F8;
    width: 125px;
    height: 125px;
    border-radius: 50%;
    position: relative;
}
    img {
        width: 125px;
        height: 125px;
    }
    .userRoleText{
        // position: absolute;
        // top: 33%;
        // left: 25%;
        font-size: 25px;
        text-align: center;
        color: #000000;
    }
}

.userInfo {
    margin-top: 12px;

    .userInfo-name {
        color: #000000;
        font-size:14px;
        line-height: 14px;
    }

    .userInfo-tel {
        color: #666666;
        font-size: 12px;
        line-height: 12px;
        margin-top: 10px;
    }
}

.contentTop {
    padding: 0px 24px;
    margin-top:171px;
    display: flex;
    align-items: center;
    width: calc(100% - 48px);

}
/deep/.van-cell-group {
    background-color: #fff;
    width: 100%;
}
/deep/.van-cell--large .van-cell__title {
    font-size: 14px;
    color: #000000;
    margin-left: 10px;
}
/deep/.van-cell, .van-cell--large,.van-cell--clickable{
    height: 40px !important;
    line-height: 40px !important;
    display: flex;
    align-items: center;
}
/*清浮动*/
.clearfix:after {
    content: '';
    display: block;
    clear: both;
}

.clearfix {
    zoom: 1;
}


.emptyContainer {
    height: 50px;

    /deep/.van-list__finished-text {
        height: 400px;
        background: palegreen;
    }
}



.btnArea{
  padding: 0px 30px;
  margin-top: 54px;
}
.loginBtn {
  width: 100%;
  height: 45px;
  border: none;
  background: #047DCB;
  border-radius:45px;
  margin-bottom:20px;
}
</style>